<#ftl strip_whitespace=true>

<#function contains list item>
    <#list list as nextInList>
    	<#if nextInList.equals(item)><#return true></#if>
    </#list>
    <#return false>
</#function>

<#macro editEntity page entity entityName additionalParameters>
	<#assign labelEdit>
		<@spring.message "edit." + entityName />
	</#assign>
	<#if additionalParameters?length &gt; 0>
		<#assign hrefSuffix = "&amp;${additionalParameters}" />
	<#else>
		<#assign hrefSuffix = "" />
	</#if>
	<a id="${entityName}-edit-${entity.id?c}" href="${rc.getContextPath()}/${entityName}/edit/${entity.id?c}?page=${page.number?c}${hrefSuffix}" alt="${labelEdit}" title="${labelEdit}"><img class="image" src="${rc.getContextPath()}/resources/images/update.png" /></a>
</#macro>
<#macro deleteEntity page entity entityName additionalParameters>
	<#assign labelDelete>
		<@spring.message "delete." + entityName />
	</#assign>
	<#if additionalParameters?length &gt; 0>
		<#assign hrefSuffix = "&amp;${additionalParameters}" />
	<#else>
		<#assign hrefSuffix = "" />
	</#if>
	<a id="${entityName}-delete-${entity.id?c}" href="${rc.getContextPath()}/${entityName}/delete/${entity.id?c}?page=${page.number?c}${hrefSuffix}" alt="${labelDelete}" title="${labelDelete}"><img class="image" src="${rc.getContextPath()}/resources/images/delete.png" /></a>
</#macro>

<#macro pagination page entityName additionalParameters>
	<#assign labelNew>
		<@spring.message "new." + entityName />
	</#assign>
	<#if additionalParameters?length &gt; 0>
		<#assign hrefSuffix = "&amp;${additionalParameters}" />
	<#else>
		<#assign hrefSuffix = "" />
	</#if>
	<a id="${entityName}-edit-0" href="${rc.getContextPath()}/${entityName}/edit/0?page=${page.number?c}${hrefSuffix}" alt="${labelNew}" title="${labelNew}"><img class="image" src="${rc.getContextPath()}/resources/images/add.png" /></a>
	<#if !page.hasContent()>
		<#return>
	</#if>
	<#assign labelFirstPage>
		<@spring.message "firstPage" />
	</#assign>
	<#assign labelPreviousPage>
		<@spring.message "previousPage" />
	</#assign>
	<#assign messageParameters = ["${(page.number + 1)?c}", "${page.totalPages?c}"] />
	<#assign labelCounterPage>
		<@spring.messageArgs "counterPage" messageParameters />
	</#assign>
	<#assign labelNextPage>
		<@spring.message "nextPage" />
	</#assign>
	<#assign labelLastPage>
		<@spring.message "lastPage" />
	</#assign>
	|
	<#if !page.firstPage>
		<a id="${entityName}-page-first" href="${rc.getContextPath()}/${entityName}/list?page=0${hrefSuffix}" alt="${labelFirstPage}" title="${labelFirstPage}"><img class="image" src="${rc.getContextPath()}/resources/images/resultset_first.png" /></a>
	</#if>
	<#if page.hasPreviousPage()>
		<#assign goPage = page.number - 1 />
		<a id="${entityName}-page-${goPage?c}" href="${rc.getContextPath()}/${entityName}/list?page=${goPage?c}${hrefSuffix}" alt="${labelPreviousPage}" title="${labelPreviousPage}"><img class="image" src="${rc.getContextPath()}/resources/images/resultset_previous.png" /></a>
	</#if>
	<span>${labelCounterPage}</span>
	<#if page.hasNextPage()>
		<#assign goPage = page.number + 1 />
		<a id="${entityName}-page-${goPage?c}" href="${rc.getContextPath()}/${entityName}/list?page=${goPage?c}${hrefSuffix}" alt="${labelNextPage}" title="${labelNextPage}"><img class="image" src="${rc.getContextPath()}/resources/images/resultset_next.png" /></a>
	</#if>
	<#if !page.lastPage>
		<#assign goPage = page.totalPages - 1 />
		<a id="${entityName}-page-last" href="${rc.getContextPath()}/${entityName}/list?page=${goPage?c}${hrefSuffix}" alt="${labelLastPage}" title="${labelLastPage}"><img class="image" src="${rc.getContextPath()}/resources/images/resultset_last.png" /></a>
	</#if>
</#macro>
